// 所有学生
<template>
  <div class="all">
    <el-table :data="pagination.records"  style="width: 100%" height="485":cell-style="cellStyle" :header-cell-style="rowClass">
      <el-table-column fixed="left" prop="requestSignupNo" label="编号" width="100"></el-table-column>
      <el-table-column prop="teacherNickname" label="昵称" width="100"></el-table-column>
      <el-table-column prop="teacherName" label="姓名" width="100"></el-table-column>
      <el-table-column prop="teacherPwd" label="密码" width="100"></el-table-column>
      <el-table-column prop="teacherDiscipline" label="学院" width="100"></el-table-column>
      <el-table-column prop="requestDate" label="申请时间" width="100"></el-table-column>
      <el-table-column prop="teacherMai" label="邮箱" width="120"></el-table-column>
      <el-table-column fixed="right" label="操作" width="150">
        <template slot-scope="scope">
          <el-button @click="accept(scope.row)" type="primary" size="small">接收</el-button>
          <el-button @click="refuse(scope.row)" type="primary" size="small">拒绝</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[1, 2]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total"
      class="page"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pagination: {
        //分页后的考试信息
        current: 1, //当前页
        total: 1, //记录条数
        size: 1 //每页条数
      }
    };
  },
  created() {
    this.getAnswerInfo();
  },
  methods: {
    cellStyle({row,column,rowIndex,columnIndex}){
      return "text-align:center";
    },
    rowClass({row,rowIndex}){
      return "text-align:center";
    },
    getAnswerInfo() {
      //分页查询所有试卷信息
      this.$axios(`/api/manage/showRequest2teacher/${this.pagination.current}/${this.pagination.size}`).then(res => {
        this.pagination = res.data.data;
      }).catch(error => {});
    },
    //改变当前记录条数
    handleSizeChange(val) {
      this.pagination.size = val;
      this.getAnswerInfo();
    },
    //改变当前页码，重新发送请求
    handleCurrentChange(val) {
      this.pagination.current = val;
      this.getAnswerInfo();
    },
    accept(val){
      this.$axios({
        url: "/api/manage/addTeacher",
        method: 'post',
        data: {
          ...val
        }
      }).then(res=>{
        let resData = res.data.data
      })
    },
    refuse(val){
      this.$axios({
        url: "/api/manage/refuseRequest",
        method: 'delete',
        data: {
          ...val
        }
      }).then(res=>{
        let resData = res.data.data
      })
    }
  }
};
</script>
<style lang="scss" scoped>
.all {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit {
    margin-left: 20px;
  }
  .el-table tr {
    background-color: #dd5862 !important;
  }
}
.el-table .warning-row {
  background: #000 !important;
}

.el-table .success-row {
  background: #dd5862;
}
</style>
